//
//  ClearView.m
//  WGFGlobalHouses
//
//  Created by waiguofang on 15/6/17.
//  Copyright (c) 2015年 waiguofang. All rights reserved.
//

#import "ClearView.h"

@implementation ClearView

-(instancetype)init
{
    if (self = [super init]) {
        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapView)];
        [self addGestureRecognizer:tap];
        self.backgroundColor = [UIColor clearColor];
    }
    
    return self;
}

+(void)showInView:(UIView *)view
{
    ClearView *clearView = [[ClearView alloc]init];
    clearView.frame = CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width/4*3, view.frame.size.height);
    [view addSubview:clearView];
    
}
-(void)hide
{
    [self.superview endEditing:YES];
    [self removeFromSuperview];
}
-(void)tapView
{
    const float movementDuration = 0.3f;
    [UIView beginAnimations: nil context: nil];
    [UIView setAnimationBeginsFromCurrentState: YES];
    [UIView setAnimationDuration: movementDuration];
    
    CGRect buf = self.superview.frame;
    buf.origin.y =  64;
    [self.superview setFrame:buf];
    [self.superview endEditing:YES];
    [UIView commitAnimations];
    
    [self hide];
    
}
@end
